using UnityEngine;

namespace CinemaDirector
{
	public class ActorTrackGroup : TrackGroup
	{
		[SerializeField]
		private Transform actor;

		protected ActorState actorState = new ActorState();

		protected TimelineTrack[] tracks_;

		public Transform Actor
		{
			get
			{
				return actor;
			}
			set
			{
				actor = value;
			}
		}

		public override void Initialize(Cutscene cutscrene)
		{
			base.Initialize(cutscrene);
			if (!Application.isPlaying)
			{
				actorState.StoreState(actor.gameObject);
			}
		}

		public override void Stop()
		{
			base.Stop();
			if (!Application.isPlaying)
			{
				actorState.RestoreStateTo(actor.gameObject);
			}
		}

		public override TimelineTrack[] GetTracks()
		{
			if (!Application.isPlaying)
			{
				return GetComponentsInChildren<ActorTrack>();
			}
			if (tracks_ == null)
			{
				tracks_ = GetComponentsInChildren<ActorTrack>();
			}
			return tracks_;
		}
	}
}
